From: Volodymyr Babchuk Date: Wed, 18 Sep 2019 18:50:56 +0000 (+0000) Subject: xen/arm: optee: check for preemption while freeing shared buffers X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~1484 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=208bef44c6e709251c4d1bbf647dc29a292119c8;p=xen.git xen/arm: optee: check for preemption while freeing shared buffers We can check for hypercall_preempt_check() in the loop inside optee_relinquish_resources() to increase hypervisor responsiveness in case if preemption is required. Signed-off-by: Volodymyr Babchuk Acked-by: Julien Grall --- diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c index d30ea2d1ac..4a31ab6088 100644 --- a/xen/arch/arm/tee/optee.c +++ b/xen/arch/arm/tee/optee.c @@ -633,17 +633,14 @@ static int optee_relinquish_resources(struct domain *d) list_for_each_entry_safe( shm_rpc, shm_rpc_tmp, &ctx->shm_rpc_list, list ) free_shm_rpc(ctx, shm_rpc->cookie); - if ( hypercall_preempt_check() ) - return -ERESTART; - - /* - * TODO: Guest can pin up to MAX_TOTAL_SMH_BUF_PG pages and all of - * them will be put in this loop. It is worth considering to - * check for preemption inside the loop. - */ list_for_each_entry_safe( optee_shm_buf, optee_shm_buf_tmp, &ctx->optee_shm_buf_list, list ) + { + if ( hypercall_preempt_check() ) + return -ERESTART; + free_optee_shm_buf(ctx, optee_shm_buf->cookie); + } if ( hypercall_preempt_check() ) return -ERESTART;